﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Nirvana
{
    public static class Vector2Extensions
    {

        public static Vector2 Parse(string text)
        {
            Vector2 result;
            if (!TryParse(text, out result))
            {
                string message = string.Format("The string {0} can not convert to Rect.", text);
                throw new FormatException(message);
            }
            return result;
        }
        private static bool TryParse(string text, out Vector2 v)
        {
            if (text.Length < 2 || text[0] != '(' || text[text.Length - 1] != ')')
            {
                v = Vector2.zero;
                return false;
            }
            string[] array = text.Substring(1, text.Length - 2).Split(new char[]
            {
                ','
            });
            if (array.Length != 2)
            {
                v = Vector2.zero;
                return false;
            }
            float num = float.Parse(array[0]);
            float num2 = float.Parse(array[1]);
            v = new Vector2(num, num2);
            return true;
        }
    }

}

